package com.cyzy.controller;

import com.cyzy.dto.*;
import com.cyzy.service.CourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author cuncun
 * @create 2025-06-19 下午7:29
 */
@RestController
@RequestMapping("/course")
public class CourseController {

    @Autowired
    private CourseService courseService;

    //根据日期查询教师课程 参数 日期、教师id
    @GetMapping("/teacherDate")
    public Result teacherDate(@RequestParam("date") String date,@RequestParam("teacherId") Integer teacherId){
        System.out.println("查询日期" + date + "-----教师Id" + teacherId);
        List<TeacherCouserDto> teacherCouserDtos = courseService.teacherDate(date, teacherId);
        return Result.ok().data("teacherCourse",teacherCouserDtos);
    }

    //根据家长id查询学生姓名和id
    @GetMapping("/studentName")
    public Result studentName(@RequestParam("parentId") Integer parentId){
        System.out.println("-----parentId" + parentId);
        List<StudentDto> StudentDtos = courseService.studentName(parentId);
        return Result.ok().data("StudentDtos",StudentDtos);
    }

    //根据学生id查询班级
    @GetMapping("/studentCla")
    public Result studentCla(@RequestParam("userName") String userName){
        System.out.println("-----userName" + userName);
        List<TeacherCouserDto> stus = courseService.studentCla(userName);
        return Result.ok().data("stus",stus);
    }

    //查询家长头像
    @GetMapping("/parentUrl")
    public Result parentUrl(@RequestParam("parentId") Integer parentId){
        System.out.println("-----parentId" + parentId);
        parentDto parent = courseService.parentUrl(parentId);
        return Result.ok().data("parent",parent);
    }

    //查询学生的一个月课程信息
    @GetMapping("/courseInformation")
    public Result courseInformation(@RequestParam("claId") Integer claId,@RequestParam("startDate") String startDate,@RequestParam("endDate") String endDate){
        System.out.println("-----claId" + claId);
        System.out.println("-----startDate" + startDate);
        System.out.println("-----endDate" + endDate);
        List<TeacherCouserDto> courses = courseService.courseInformation(claId,startDate,endDate);
        return Result.ok().data("courses",courses);
    }

    //根据日期查询学生的该天课程
    @GetMapping("/dateSelectCourse")
    public Result dateSelectCourse(@RequestParam("claId") Integer claId,@RequestParam("date") String date){
        System.out.println("-----claId" + claId);
        System.out.println("-----date" + date);
        List<TeacherCouserDto> couser = courseService.dateSelectCourse(claId,date);
        return Result.ok().data("couser",couser);
    }

    //查询教师头像路径
    @GetMapping("/teacherUrl")
    public Result teacherUrl(@RequestParam("teacherId") Integer teacherId){
        System.out.println("-----teacherId" + teacherId);
        TeacherDto teacher = courseService.teacherUrl(teacherId);
        return Result.ok().data("teacher",teacher);
    }
}
